<%--
  Created by IntelliJ IDEA.
  User: admin
  Date: 2023/6/17
  Time: 16:19
  To change this template use File | Settings | File Templates.
--%>
<%@ page import="java.sql.Statement" %>
<%@ page import="java.sql.ResultSet" %>
<%@ page import="java.sql.Connection" %>
<%@ page import="java.sql.DriverManager" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>协同过滤</title>
</head>
<center>

    <div id="app">
        <div class="content-header">
            <center><h1 style="color: #f56c6c">学生信息管理</h1></center>
            <br>
            <h1>学生管理</h1>
        </div>

        <div style="position: center" >
            <form action="/Student" method="get">
                name<input type="text" name="name"><br>
                <input type="submit"  >
            </form>
        </div>

        <div>
            <table>
                <thead>
                <tr>
                    <th>姓名</th>
                    <th>GPA</th>
                    <th>科目</th>
                </tr>
                </thead>
                <tbody id="json-container"></tbody>
            </table>
        </div>

        <script>
            fetch('servlet')
                .then(response => response.json())
                .then(data => {
                    const container = document.getElementById('json-container');

                    // 遍历JSON数据并创建HTML元素
                    data.forEach(item => {
                        const tr = document.createElement('tr');
                        tr.innerHTML = `<td>${item.name}</td>
                           <td>${item.gpa}</td>
                           <td>${item.subject}</td>`;
                        container.appendChild(tr);
                    });
                });
        </script>
    </div>
</center>
</html>

